package com.ukao.cashregister.adapter;

import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import android.widget.TextView;

import com.mcxtzhang.commonadapter.rv.CommonAdapter;
import com.mcxtzhang.commonadapter.rv.ViewHolder;
import com.ukao.cashregister.R;
import com.ukao.cashregister.bean.PieBean;
import com.ukao.cashregister.consts.Constant;
import com.ukao.cashregister.utils.CheckUtils;

import java.util.List;

/**
 * Created by ukaodev on 2017/6/14.
 */

public class PieLeftAdapter extends CommonAdapter<PieBean> {



    private  boolean isboottomPie;
    public PieLeftAdapter(Context context, List<PieBean> datas) {
        super(context, datas, R.layout.adapter_pie_left);
    }

    public  void  setboottomPie(boolean  isboottomPie){
        this.isboottomPie=isboottomPie;
    }

    @Override
    public void convert(final ViewHolder holder, final PieBean item) {

        TextView payMethodText = holder.getView(R.id.payMethodText);
        TextView state = holder.getView(R.id.state);
        payMethodText.setText(item.getPayMethodText()+"："+CheckUtils.isEmptyNumber(item.getPayAmount())+"元");
        GradientDrawable myGrad = (GradientDrawable)state.getBackground();
    if (isboottomPie){
        myGrad.setColor(Constant.VORDIPLOM_COLOR1[getPosition(holder)]);
    }else{
        myGrad.setColor(Constant.VORDIPLOM_COLOR[getPosition(holder)]);
    }


    }

}
